package cn.gson.boot.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.Objects;

@Entity
@Table(name = "salesdetails_", schema = "boot", catalog = "")
public class Salesdetails {//销售机会从表
    private int detailsId;//销售从表id
    private Integer sproductNum;//数量
    private BigDecimal sproductSubtotal;//小计
    private Productt productt;//产品id
    private Sales sales;//销售机会id

    @Id
    @Column(name = "details_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getDetailsId() {
        return detailsId;
    }

    public void setDetailsId(int detailsId) {
        this.detailsId = detailsId;
    }

    @Basic
    @Column(name = "sproduct_num", nullable = true)
    public Integer getSproductNum() {
        return sproductNum;
    }

    public void setSproductNum(Integer sproductNum) {
        this.sproductNum = sproductNum;
    }

    @Basic
    @Column(name = "sproduct_subtotal", nullable = true, precision = 2)
    public BigDecimal getSproductSubtotal() {
        return sproductSubtotal;
    }

    public void setSproductSubtotal(BigDecimal sproductSubtotal) {
        this.sproductSubtotal = sproductSubtotal;
    }

    @ManyToOne(/*cascade=CascadeType.PERSIST*/)
    @JoinColumn(name = "sales_id", referencedColumnName = "sales_id")
    public Sales getSales() {
        return sales;
    }

    public void setSales(Sales sales) {
        this.sales = sales;
    }

    @ManyToOne()
    @JoinColumn(name = "productt_id", referencedColumnName = "productt_id")
    public Productt getProductt() {
        return productt;
    }

    public void setProductt(Productt productt) {
        this.productt = productt;
    }

    @Override
    public String toString() {
        return "Salesdetails{" +
                "detailsId=" + detailsId +
                ", sproductNum=" + sproductNum +
                ", sproductSubtotal=" + sproductSubtotal +
                ", productt=" + productt +
                '}';
    }
}
